package com.tianqu.tms.www.transfer.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tianqu.tms.core.base.Logger;
import com.tianqu.tms.core.base.TmsAction;
import com.tianqu.tms.core.base.UserContext;
import com.tianqu.tms.core.util.TmsConstants;
import com.tianqu.tms.www.transfer.controller.TransferReAcceptListController;
import com.tianqu.tms.www.transfer.viewhelper.TransferRgInputViewHelper;

public class TransferReAcceptListAction extends TmsAction{

	private Logger logger = Logger.getLogger(TransferReAcceptListAction.class);
	public static final String REACLIST = "reAcList";
	@Override
	protected ActionForward doAction(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response,
			UserContext uc) throws Exception {
		logger.debug(this.getClass().getName() + "#execute was called.");
		TransferReAcceptListController controller = new TransferReAcceptListController();
		controller.execute(uc);
		List reAcceptList = (List)uc.getAttribute(TransferReAcceptListController.REACCEPTLIST);
		TransferRgInputViewHelper viewhelp = new TransferRgInputViewHelper();
		viewhelp.setReAcceptList(reAcceptList);
		uc.setAttribute(REACLIST, reAcceptList);
		String error = (String)uc.getAttribute("errorFlag");
		if(error != null && error != ""){
			viewhelp.setErrorFlag(1);
			viewhelp.setErrorLicense(error);
		}
		uc.removeAttribute("reFlag");
		uc.removeAttribute("errorFlag");
		request.setAttribute(TmsConstants.VIEWHELP, viewhelp);
		logger.debug(this.getClass().getName() + "#execute was completed.");
		return mapping.findForward(TmsConstants.SUCCESS);
	}
}
